<?php
/**
 * Lets you add/remove the different parts of an email.ie. body,to-s,from etc
 *
 * @author Ishtiaque Shahrier <md.ishtiaque@newgenbd.net>
 * @package email
 * @subpackage models
 */
class email_m_email {

    protected $_from;
    protected $_to;
    protected $_cc;
    protected $_bcc;
    protected $_body;
    protected $_subject;    
    /**
     * @var bool Is the email in HTML format
     */
    protected $is_html ;
    
    public function __construct($is_html=FALSE) {
        $this->_bcc = array();
        $this->_cc = array();
        $this->_from = array();
        $this->_to = array();
        $this->is_html = $is_html;
    }

    public function is_html(){
        return $this->is_html;
    }
    public function add_to($address, $name) {
        $this->_to[$address] = $name;
    }

    public function add_from($address, $name) {
        $this->_from[$address] = $name;
    }

    public function add_cc($address, $name) {
        $this->_cc[$address] = $name;
    }

    public function add_bcc($address, $name) {
        $this->_bcc[$address] = $name;
    }

    public function get_tos() {
        return $this->_to;
    }

    public function get_from() {
        return $this->_from;
    }

    public function get_ccs() {
        return $this->_cc;
    }

    public function get_bccs() {
        return $this->_bcc;
    }

    public function set_body($body) {
        $this->_body = $body;
    }

    public function get_body() {
        return $this->_body;
    }

    public function set_subject($subject) {
        $this->_subject = $subject;
    }

    public function get_subject() {
        return $this->_subject;
    }

    /**
     * @internal for debugging purpose
     * @return string
     */
    public function  __toString() {
        $output = array();
        $output[] = "From: ".print_r($this->get_from(),true);
        $output[] = "To: ".print_r($this->get_tos(),true);
        $output[] = "Cc: ".print_r($this->get_ccs(),true);
        $output[] = "Bcc: ".print_r($this->get_bccs(),true);
        $output[] = "Subject: ".$this->get_subject();
        $output[] = "Body: ".$this->get_body();
        $output[] = $this->is_html() ? "**This <strong>IS</strong> a html message**" : "This is <strong>NOT</strong> a html message";

        return implode("<br/>", $output);

    }

}
?>
